<form>
<h2>Which permission to change?</h2>
<p class="action-options">
  <label>Privilege</label>
  <%= select_tag :privilege, options_for_select(@privileges.map {|p| [human_privilege(p), p.to_s]}.sort, @privilege.to_s) %>
  <br/>
  <label>On</label>
  <%= select_tag :context, options_for_select(@contexts.map {|c| [human_context(c), c.to_s]}.sort, @context.to_s) %>
  <br/>
  <label></label>
  <%= link_to "Show current permissions", '#', onclick: "show_current_permissions()", :class => 'unimportant' %>
  <br/><br/>
  How many users should be <strong>affected</strong>?
  <br/>
  <label></label>
  <%= radio_button_tag :affected_users, :few, params[:affected_users] == 'few' %>
  <label class="inline">A <strong>few</strong> users</label>
  <%= radio_button_tag :affected_users, :many, params[:affected_users] == 'many' %>
  <label class="inline"><strong>Many</strong> users</label>
</p>

<h2>Whose permission should be changed?</h2>
<table class="change-options">
  <thead>
    <tr>
      <td>User</td>
      <td>Current roles</td>
      <td class="choose">?</td>
      <td class="choose">Yes</td>
      <td class="choose">No</td>
    </tr>
  </thead>
  <tbody>
    <% @users.each do |user| %>
      <tr class="<%= controller.authorization_engine.permit?(@privilege, :context => @context, :user => user, :skip_attribute_test => true) ? 'permitted' : 'not-permitted' %>">
        <td class="user_id"><%=h user.id %></td>
        <td style="font-weight:bold"><%=h user.login %></td>
        <td><%=h user.role_symbols.map {|r| human_role(r)} * ', ' %></td>
        <td><%= radio_button_tag "user[#{user.id}][permission]", "undetermined", true %></td>
        <td class="yes"><%= radio_button_tag "user[#{user.id}][permission]", "yes" %></td>
        <td class="no"><%= radio_button_tag "user[#{user.id}][permission]", "no" %></td>
      </tr>
    <% end %>
    <tr>
      <td colspan="5" style="text-align:right; padding-top:0.5em" class="unimportant">
        <span style="background: #FFE599;">&nbsp; &nbsp;</span> Current permission
      </td>
    </tr>
  </tbody>
</table>

<h2 style="display:none">Prohibited actions</h2>
<ul id="prohibited_actions"></ul>

<p class="submit">
  <%= button_to "Suggest Changes", '#', onclick: "suggest_changes()" %>
</p>
</form>